#!/bin/bash
jdk_home="/usr/local/java"
soft_dir="/opt/jdk"
echo "创建jdk软件包目录"$soft_dir;
mkdir $soft_dir
########################################################
#############       安装 jdk-11.0.2        ##############
########################################################
cd $soft_dir;
echo "执行下载解压jdk-11.0.2------------------------------------------>";
wget "https://mirrors.huaweicloud.com/java/jdk/11.0.2+7/jdk-11.0.2_linux-x64_bin.tar.gz";
mkdir $jdk_home
tar -zxvf jdk-11.0.2_linux-x64_bin.tar.gz -C $jdk_home
cd $jdk_home
#配置环境变量
echo "开始配置java环境变量！------------------------------------------>"
echo "export JAVA_HOME=/usr/local/java/jdk-11.0.2" >> /etc/profile;
echo "export CLASSPATH=\$JAVA_HOME/lib/rt.jar:\$JAVA_HOME/lib/tools.jar" >> /etc/profile;
echo "export PATH=\$JAVA_HOME/bin:\$PATH" >> /etc/profile;
# 刷新环境变量
source /etc/profile
echo "安装完毕,下面进行测试!------------------------------------------>"
java -version
